package com.lulin.mall.order.utils;

import com.lulin.common.constant.OrderConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 订单消息发送者
 *
 * @author lulin
 * @date 2022/12/29 14:23
 */
@Component
public class OrderMsgProducer {

    @Autowired
    RocketMQTemplate rocketMQTemplate;

    /**
     * 发送消息
     *
     * @param orderSn 订单编号
     */
    public void sendOrderMsg(String orderSn) {
        rocketMQTemplate.syncSend(OrderConstant.ROCKETMQ_ORDER_TOPIC,
                MessageBuilder.withPayload(orderSn).build(),
                5000,
                3);//16等级，30分钟,测试先设置3 ，10s看效果
    }
}
